/**
 * request Service:/show_person
*/
#include <ros/ros.h>
#include "learn_service_userdef/Person.h"

class ServicePersonClient {
 public:
  ServicePersonClient(std::string service_name) {
    ros::service::waitForService(service_name);
    person_srv_client_ = nh_.serviceClient<learn_service_userdef::Person>(service_name);
    learn_service_userdef::Person srv_data;
    srv_data.request.name = "David";
    srv_data.request.age = 26;
    srv_data.request.sex = learn_service_userdef::Person::Request::male;
    ROS_INFO("Call service to show person[name:%s,age:%d,sex:%d]",
      srv_data.request.name.c_str(), srv_data.request.age, srv_data.request.sex);
    person_srv_client_.call(srv_data);
    ROS_INFO("Show service person call result: %s", srv_data.response.result.c_str());
  }

  ~ServicePersonClient() {

  }

 private:
  ros::NodeHandle nh_;
  ros::ServiceClient person_srv_client_;

};

int main(int argc, char** argv) {
  ros::init(argc, argv, "service_person_client");
  ServicePersonClient client_node("/show_person");
  return 0;
}
